#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;
int n;
const int N = 5e5 + 10;
int a[N];
int tmp[N];
typedef long long ll;
ll merge(int left, int right)
{
    if (left >= right)
        return 0;
    int mid = (right + left) / 2;
    ll ret = 0;
    ret += merge(left, mid);
    ret += merge(mid + 1, right);
    int cn1 = left;
    int cn2 = mid;
    int cn3 = mid + 1;
    int cn4 = right;
    int i = left;
    while (cn1 <= cn2 && cn3 <= cn4)
    {
        if (a[cn1] <= a[cn3])
        {
            tmp[i++] = a[cn1++];
        }
        else
        {
            ret += cn2 - cn1 + 1;
            tmp[i++] = a[cn3++];
        }
    }
    while (cn1 <= cn2) tmp[i++] = a[cn1++];
    while (cn3 <= cn4) tmp[i++] = a[cn3++];
    for (int j = left; j <= right; j++)
    {
        a[j] = tmp[j];
    }
    return ret;
}
int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    cout << merge(1, n) << endl;
    return 0;
}